﻿//-----------------------------------------------------------------------
// <copyright file="ParameterUtility.cs">
//     Copyright (c) Nicole Calinoiu. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Linq;

using Microsoft.FxCop.Sdk;

namespace Bordecal.FxCop.Sdk
{
	/// <summary>
	/// Extension methods for the <see cref="Parameter"/> type.
	/// </summary>
	public static class ParameterUtility
	{
		/// <summary>
		/// Determines whether a <see cref="Parameter"/> has a <see cref="ParamArrayAttribute"/>.
		/// </summary>
		/// <param name="parameter">The target <see cref="Parameter"/>.</param>
		/// <returns>True if the parameter is a parameter array; otherwise, false.</returns>
		public static bool IsParameterArray(this Parameter parameter)
		{
			if (parameter == null)
			{
				throw new ArgumentNullException("parameter");
			}

			return parameter.Attributes.Any(a => a.Type == Types.ParamArrayAttribute);
		}
	}
}